<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="application/javascript" src="/client/js/jquery.min.js"></script>
<script type="text/javascript">
/**
 * my_click和my_blur均是用于前台页面搜索框的函数
 */
//鼠标点击搜索框时执行
function my_click(obj, myid){
	//点击时，如果取得的值和搜索框默认value值相同，则将搜索框清空
	if (document.getElementById(myid).value == document.getElementById(myid).defaultValue){
	  document.getElementById(myid).value = '';
	  obj.style.color='#000';
	}
}
//鼠标不聚焦在搜索框时执行
function my_blur(obj, myid){
	//鼠标失焦时，如果搜索框没有输入值，则用搜索框的默认value值填充
	if (document.getElementById(myid).value == ''){
	 document.getElementById(myid).value = document.getElementById(myid).defaultValue;
	 obj.style.color='#999';
 }
}

/**
 * 点击搜索按钮执行的函数
 */
function search(){
	document.getElementById("searchform").submit();
}

$(function(){
	$.ajax({
		url:"/main/category.do",
		type:"post",
		dataType:"json",
		success:function (data) {
			var mycategory = $("#divmenu").html("");
			var str = "";
			for (var i = 0;i<data.length && i<14 ;i++){
				str = str+"<a href=\"${pageContext.request.contextPath}/main/pageProduct.do?currentPage=1&cid="+data[i].id+"\">"+data[i].name+"</a> ";
			}
			str = str+"<a href=\"${pageContext.request.contextPath}/main/pageProduct.do?currentPage=1\" style=\"color:#b4d76d\">全部商品目录</a>"
			mycategory.append(str);
		}
	})

});
</script>

<%--<div id="divmenu" >--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=文学">文学</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=生活">生活</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=计算机">计算机</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=外语">外语</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=经营">经管</a>&ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=励志">励志</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=社科">社科</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=学术">学术</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=少儿">少儿</a>&ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=艺术">艺术</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=原版">原版</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=科技">科技</a> &ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=考试">考试</a>&ndash;%&gt;--%>
		<%--&lt;%&ndash;<a href="${pageContext.request.contextPath}/showProductByPage?category=生活百科">生活百科</a> &ndash;%&gt;--%>
		<%--<c:forEach items="${list}" var="c">--%>
			<%--<a href="${pageContext.request.contextPath}/main/pageProduct.do?currentPage=1&cid=${c.id}">${c.name}</a>--%>
		<%--</c:forEach>--%>
		<%--<a href="${pageContext.request.contextPath}/main/pageProduct.do?currentPage=1" style="color:#b4d76d">全部商品目录</a>--%>
<%--</div>--%>
<div id="divmenu">
	<a href="${pageContext.request.contextPath}/main/category.do" style="color: #2b542c">更多分类查询</a>
</div>
<div id="divsearch">
<form action="${pageContext.request.contextPath }/main/searchProduct.do" id="searchform">
	<table width="100%" border="0" cellspacing="0">
		<tr>
			<td style="text-align:right; padding-right:220px">
				Search 
				<input type="text" name="name" class="inputtable" id="textfield" value="请输入书名"
				onmouseover="this.focus();"
				onclick="my_click(this, 'textfield');"
				onBlur="my_blur(this, 'textfield');"/> 
				<a href="#">
					<img src="${pageContext.request.contextPath}/client/images/serchbutton.gif" border="0" style="margin-bottom:-4px" onclick="search()"/>
				</a>
			</td>
		</tr>
	</table>
</form>
</div>